const app = new Vue({
  data: {
    title: '待办事项',
    todolist: [],
    text: ''
  },
  created() {
    fetch('https://api.yizhanketang.cn/api/v1/todos')
      .then((res) => {
        return res.json()
      })
      .then(res => {
        const { data } = res
        this.todolist = data
      })
  },
  methods: {
    creatTodo() {
      if (!this.text) {
        return false
      }

      fetch('https://api.yizhanketang.cn/api/v1/todos', {
        method: 'POST',
        body: JSON.stringify({
          content: this.text
        }),
        headers: {
          'content-type': 'application/json'
        },
      }).then((res) => {
        return res.json()
      })
        .then(res => {
          console.log(res)
        })
      // console.log(this.text)
    }
  }
  // mounted() {},
}).$mount('#app')
